package com.leon.androidcoursedesign.ui.activitys;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener {

    public abstract int setLayout();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(setLayout());

        initView();
        initValue();
    }

    public abstract void initView();
    public abstract void initValue();

    private View findView(int viewId) {
        return findViewById(viewId);
    }

    /**
     * 设置监听
     *
     * @param viewId    控件ID
     * @return  返回this
     */
    public BaseActivity setOnClick(int viewId) {
        View view = findView(viewId);
        view.setOnClickListener(this);

        return this;
    }
}
